package org.bringer.model;

import java.io.Serializable;
import java.util.Calendar;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.hibernate.annotations.AccessType;


@Entity
@Table(name = "annotation")
@AccessType("field")
public class Annotation extends BaseObject implements Serializable {
    

    /**
	 * 
	 */
	private static final long serialVersionUID = -6678155707798084635L;
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)    
	private Long id;
	@Column(nullable = false, length = 100)    
	private String description;
	@Column(nullable = false)
    private Double amount; 
    @Column(nullable = false)
    @Temporal(TemporalType.TIMESTAMP)	    
    private Calendar annotationDate;
    @Column(nullable = true)
    private Integer version;  
    @ManyToOne    
    @JoinColumn(name="account_id")
    private Account account;

    public Account getAccount() {
		return account;
	}



	public void setAccount(Account account) {
		this.account = account;
	}



	public void setId(Long id) {
		this.id = id;
	}



	public void setAmount(Double amount) {
		this.amount = amount;
	}



	



	public void setVersion(Integer version) {
		this.version = version;
	}



	/**
     * Default constructor - creates a new instance with no values set.
     */
    public Annotation() {
    }

    

  
    public Long getId() {
        return id;
    }

    
    public Calendar getAnnotationDate() {
        return annotationDate;
    }

   
    public Double getAmount() {
        return amount;
    }


    @Version
    public Integer getVersion() {
        return version;
    }

    public String toString() {
        ToStringBuilder sb = new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE)
                .append("annotationDate", this.annotationDate)
                .append("amount", this.amount);

     
        return sb.toString();
    }



	@Override
	public boolean equals(Object o) {
		// TODO Auto-generated method stub
		 if (this == o) {
	            return true;
	        }
	        if (!(o instanceof Annotation)) {
	            return false;
	        }

	        final Annotation user = (Annotation) o;

	     return !(id != null ? !id.equals(user.getId()) : user.getId() != null);

	}



	@Override
	public int hashCode() {
		// TODO Auto-generated method stub		
		 return (annotationDate != null ? annotationDate.hashCode() : 0);
	}


	
	public String getDescription() {
		return description;
	}



	public void setDescription(String description) {
		this.description = description;
	}



	public void setAnnotationDate(Calendar annotationDate) {
		this.annotationDate = annotationDate;
	}
	
}
